package com.example.financecollegeorderdish.db.dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;


import com.example.financecollegeorderdish.db.bean.DishBean;

import java.util.List;

/**
 * @author zhangjianhao
 * @date 2022/1/17
 */
@Dao
public interface DishBeanDao {
    @Insert
    Long insertOne(DishBean bean);

    @Insert
    void insertList(List<DishBean> beans);

    @Query("SELECT * FROM DishBean ")
    LiveData<List<DishBean>> queryAll();


    @Query("SELECT count(*) FROM DishBean")
    int countAll();

    @Update
    void updateList(List<DishBean> user);
    @Update
    int updateOne(DishBean user);

    @Delete
    void deleteOne(DishBean one);

    @Query("DELETE FROM DishBean")
    void deleteAll();

    @Query("DELETE FROM DishBean where primaryKey = :primaryKey")
    void deleteByPrimaryKey(Long primaryKey);

    @Query("SELECT count(*) FROM DishBean where primaryKey = :primaryKey")
    int countByPrimaryKey(Long primaryKey);

    @Query("SELECT * FROM DishBean where primaryKey = :primaryKey")
    DishBean queryByKey(Long primaryKey);

    @Query("SELECT DISTINCT taste from DishBean")
    LiveData<List<String>> getTasteList();

    @Query("SELECT * from DishBean where taste in (:tasteList) limit :limitNum")
    List<DishBean> queryByCondition(List<String> tasteList,int limitNum);

    @Query("SELECT * FROM DishBean ")
    List<DishBean> queryAllNoLive();
}
